package day11.demo1;

/**
 * @Author juzipi
 * @Date 2021/6/28 15:04
 * @Info
 */
public class AnimalTest {

    public static void main(String[] args) {
        AnimalTest animalTest = new AnimalTest();
        animalTest.func(new Dog());
        animalTest.func(new Cat());

    }

    //不用多态的话就需要 创建两个参数不同的方法分别传 Dog 和 Cat
    public void func(Animal animal){
        animal.eat();
        animal.shout();
    }

}

class Animal{

    public void eat(){
        System.out.println("进食");
    }

    public void shout(){
        System.out.println("the 叫");
    }

}

class Dog extends Animal{

    @Override
    public void eat() {
        System.out.println("狗吃战斧牛排");
    }

    @Override
    public void shout() {
        System.out.println("狺狺狂吠");
    }

}

class Cat extends Animal {

    @Override
    public void eat() {
        System.out.println("猫吃鱼");
    }

    @Override
    public void shout() {
        System.out.println("喵喵");
    }

}
